
function isObjectValueEqualNew (a, b) {
  var aProps = Object.getOwnPropertyNames(a);
  var bProps = Object.getOwnPropertyNames(b);
  if (aProps.length != bProps.length) {
    return false;
  }
  for (var i = 0; i < aProps.length; i++) {
    var propName = aProps[i]
    var propA = a[propName]
    var propB = b[propName]
    if (propA !== propB) {
      return false
    }
    return true
  }
}
function unique(arr) {
  for (var i = 0; i <  arr.length; i++) {
    for (var j = i + 1; j <  arr.length; j++) {
      if (isObjectValueEqualNew(arr[i] ,arr[j])) {
        arr.splice(j, 1);
        j--;  // 每删除一个数j的值就减1
      }
    }
  }
  return arr;
}


const state = {
  // versionList
  versionList:JSON.parse(localStorage.getItem("versionList")) || [],
  versionInfo:JSON.parse(localStorage.getItem("versionInfo")) || {},
}

const mutations = {
  setversionList: (state, item) => {
    console.log("systemList,",item)
    // state.versionList.push(item)  //  by wf
    state.versionList = [item]
    // state.versionList = unique(state.versionList)  //  by wf
    // console.log("去重后的versionList",state.versionList)  //  by wf
    localStorage.setItem("versionList",JSON.stringify(state.versionList))
  },
  setversionInfo: (state, item) => {
    state.versionInfo = item
  },

  clearState:(state)=>{
    state.versionList = []
    state.versionInfo = {}
  }
}

const actions = {


}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}

